package com.briup.mt.service.impl;


import com.briup.mt.bean.BaseUserRole;
import com.briup.mt.bean.BaseUserRoleExample;
import com.briup.mt.dao.BaseUserRoleMapper;
import com.briup.mt.service.IBaseUserRoleService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BaseUserRoleServiceImpl implements IBaseUserRoleService {
    @Resource
    BaseUserRoleMapper userRoleMapper;

    @Override
    public List<BaseUserRole> query(Long id){
        BaseUserRoleExample example=new BaseUserRoleExample();
        if(!StringUtils.isEmpty(id)){
            example.createCriteria().andIdEqualTo(id);
        }
        List<BaseUserRole> list= userRoleMapper.selectByExample(example);
        return list;
    }
    @Override
    public BaseUserRole findById(long id){
        return userRoleMapper.selectByPrimaryKey(id);
    }

    @Override
    public String saveOrUpdate(BaseUserRole userRole){
        if (userRole.getId()!=null){
            userRoleMapper.updateByPrimaryKey(userRole);
            return "更新成功";
        }
        userRoleMapper.insert(userRole);
        return "保存成功";
    }
     @Override
     public void deleteById(long id){
            userRoleMapper.deleteByPrimaryKey(id);
        }
}




